import 'package:flutter/material.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'multi_state_widget.dart';

class DefaultEmptyWidget extends StatefulWidget {
  final Color backGroundColor;
  final MultiModel? model;
  final MultiEmptyType emptyType;
  final String emptyIcon;
  final String emptyText;

  DefaultEmptyWidget({
    Key? key,
    this.backGroundColor = Colours.color_background,
    this.model = MultiModel.normal,
    this.emptyType = MultiEmptyType.normal,
    this.emptyIcon = "images/ic_empty.png",
    this.emptyText = "暂无任何数据",
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _DefaultEmptyWidgetState();
  }
}

class _DefaultEmptyWidgetState extends State<DefaultEmptyWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: widget.backGroundColor,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(getEmptyIconName()),
            SizedBox(
              height: 5.w,
            ),
            Text(
              widget.emptyText,
              style: TextStyle(
                color: Colours.color_333333_50,
                fontSize: 14.sp,
              ),
            ),
          ],
        ),
      ),
    );
  }

  String getEmptyIconName() {
    if (widget.model == null) {
      return widget.emptyIcon;
    }
    switch (widget.emptyType) {
      case MultiEmptyType.normal:
        return widget.model == MultiModel.normal ? "images/ic_empty.png" : "images/ic_empty_tint.png";
      case MultiEmptyType.record:
        return widget.model == MultiModel.normal ? "images/ic_empty_record.png" : "images/ic_empty_record_tint.png";
      case MultiEmptyType.message:
        return widget.model == MultiModel.normal ? "images/ic_empty_message.png" : "images/ic_empty_message_tint.png";
      default:
        return widget.model == MultiModel.normal ? "images/ic_empty.png" : "images/ic_empty_tint.png";
    }
  }
}
